﻿using System;
using System.Windows;
using hStatsC.Models;
using Panuon.UI.Silver;
using PropertyChanged;

namespace hStatsC.Views
{
    [AddINotifyPropertyChangedInterface]
    public partial class AppVersionDetailView : Window
    {
        public AppVersion Version { get; set; }
        public bool isNew { get; set; }
        
        public AppVersionDetailView(bool isnew,string appid)
        {
            InitializeComponent();
            DataContext = this.Version;
            isNew = isnew;
            if (isNew)
            {
                this.Version = new AppVersion()
                {
                    App = appid,
                    UpdateTime = DateTime.Now
                };
                DataContext = this.Version;
            }
        }
        
        private void Btn_OK(object sender, RoutedEventArgs e)
        {
            if (isNew)
            {
                if (this.Version.App != "" && Version.DownloadLink!="")
                {
                    DialogResult=true;
                    this.Close();
                }
                else
                {
                    MessageBoxX.Show("部分参数为空", "错误!");
                }
            }
            else
            {
                this.Close();
            }
        }
    }
}